package com.smitish.vueblog.mapper;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.smitish.vueblog.entity.Comment;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.smitish.vueblog.vo.BlogUserVO;
import com.smitish.vueblog.vo.CommentUserVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * Mapper 接口
 * </p>
 *
 * @author Smitish
 * @since 2020-12-02
 */
public interface CommentMapper extends BaseMapper<Comment> {

    /**
     * @param page 页码
     * @param id   文章ID
     * @return 返回多表连接结果集
     */
    @Select("SELECT m_comment.*,m_user.`avatar` FROM m_comment,m_user WHERE m_comment.user_id=m_user.id AND post_id = ${post_id} ORDER BY created DESC")
    List<CommentUserVO> getCommentUser(Page<CommentUserVO> page, @Param("post_id") Long id);


}
